<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <base href="${rc.contextPath}/">
    <title>绑定用户</title>
    <meta name="keywords" content="绑定用户">
    <meta name="description" content="绑定用户">

    <#include "/commons/stylesheets.ftl">

    <link href="/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="/layer/skin/layer.css" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                    <form class="form-horizontal m-t" id="commitForm" action="${rc.contextPath}/activity/bindCustomer" method="post">
                        <input type="hidden" id="activityId" name="activityId" value="${activity.id}"/>
                        <input type="hidden" id="customerInfos" name="customerInfos" />
                        <input type="hidden" id="isLimited" name="isLimited" value="${activity.isLimited!'0'}"/>
                        <input type="hidden" id="limitNumber" name="limitNumber" value="${activity.limitNumber!''}"/>
                        <input type="hidden" id="searchGender" name="searchGender" />
                        <input type="hidden" id="searchAge" name="searchAge" />
                        <input type="hidden" id="searchMills" name="searchMills" />
                        <input type="hidden" id="searchAgeLimit" name="searchAgeLimit" />
                        <input type="hidden" id="searchStartTime" name="searchStartTime" />
                        <input type="hidden" id="searchEndTime" name="searchEndTime" />
                        <input type="hidden" id="searchVehicles" name="searchVehicles" />
                        <input type="hidden" id="searchVehicleIds" name="searchVehicleIds" />
                        <input type="hidden" id="selectCustomers" name="selectCustomers" value="${selectCustomers!''}"/>
                         <div class="form-group">
                            <label class="col-sm-2 control-label">活动企业
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.companyNames!''}</p>
                            </div>
                         </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动内容
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.activityDesc!''}</p>
                            </div>
                        </div>
                        <#if "${activity.limitNumber!''}" != "">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">预发数量
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.limitNumber!''}份</p>
                            </div>
                        </div>
                        </#if>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动名称
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.activityName!''}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动时间
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.startTime?string("yyyy-MM-dd HH:mm:ss")}至${activity.endTime?string("yyyy-MM-dd HH:mm:ss")}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动地点
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.activityLocation!''}</p>
                            </div>
                        </div>

                         <div class="form-group">
                            <label class="col-sm-2 control-label">活动区域
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${organizationName!''}</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">发送方式
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">
                                     <#if activity.smsSendType == 1>
                                            立即发送
                                     <#elseif activity.smsSendType == 2>
                                            定时发送
                                     </#if>
                                 </p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">验证方式
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">
                                    <#if activity.verifyType == 1>
                                         二维码
                                    <#elseif activity.verifyType == 2>
                                         数字码
                                    </#if>
                                 </p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">发送内容
                            </label>
                            <div class="col-sm-10">
                                 <p class="text-left">${activity.smsTemplate!''}</p>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">活动对象</label>

                            <div class="col-sm-10">
                               <p class="text-left">如活动对象为<span style="color:red;">男性</span>，且车辆为<span style="color:red;">三万公里以内</span>的<span style="color:red;">宝马5系</span>用户人群</p>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">对象唯一性
                            </label>

                            <div class="col-sm-10">
                                 <label class="checkbox-inline i-checks">
                                     <input type="radio" checked="" value="1" name="activityTargetType">按个人</label>
                                 <label class="checkbox-inline i-checks">
                                     <input type="radio" value="2"  name="activityTargetType">按车型</label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">对象类型
                            </label>

                            <div class="col-sm-10">
                                <label class="checkbox-inline"><a  href="javaScript:bindCustomerDiag(${activity.id});" >选择用户对象</a> </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="button" onClick="bindCustomer();">绑定</button>
                                <button type="button" class="btn btn-success" onClick="cancel(${activity.id});">取消</button>
                            </div>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <#include "/commons/scripts.ftl">

    <!-- jQuery Validation plugin javascript-->
    <script src="/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="/js/plugins/validate/messages_zh.min.js"></script>

    <script src="/layer/layer.js"></script>
    <script src="/js/app.js"></script>
    <script type="text/javascript" src="/bootstrap-table/bootstrap-table.min.js"></script>
    <script type="text/javascript" src="/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!-- Data picker -->
    <script src="/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script>
        $.validator.setDefaults({
            highlight:function(a){$(a).closest(".form-group").removeClass("has-success").addClass("has-error")},
            success:function(a){a.closest(".form-group").removeClass("has-error").addClass("has-success")},errorElement:"span",
            errorPlacement:function(a,b){if(b.is(":radio")||b.is(":checkbox")){a.appendTo(b.parent().parent().parent())}else{a.appendTo(b.parent())}},errorClass:"help-block m-b-none",validClass:"help-block m-b-none"});

            $().ready(function(){
                $("#dataRange .input-daterange").datepicker({
                    keyboardNavigation:false,
                    forceParse:false,autoclose:true
                });

                $("#dataSelect .input-group.date").datepicker({
                    todayBtn:"linked",
                    keyboardNavigation:false,
                    forceParse:false,
                    calendarWeeks:true,
                    autoclose:true
                });
            });

            function bindCustomer() {
                if($("#customerInfos").val() == '') {
                    layer.msg('请先绑定用户');
                    return false;
                }
                $("#commitForm").submit();
            }

            function refreshCustomer(customerIds,customerInfos,searchMap){
                $("#customerInfos").val(customerInfos);
                $("#selectCustomers").val(customerIds);
                $("#searchGender").val(searchMap.gender);
                $("#searchAge").val(searchMap.age);
                $("#searchMills").val(searchMap.mills);
                $("#searchAgeLimit").val(searchMap.vehicleAgeLimit);
                $("#searchStartTime").val(searchMap.startTime);
                $("#searchEndTime").val(searchMap.endTime);
                $("#searchVehicles").val(searchMap.selectedVehicles);
                $("#searchVehicleIds").val(searchMap.selectedVehicleIds);
            }



            function bindCustomerDiag(activityId) {
                //console.log("selectCustomers:" + $("#selectCustomers").val());
                var activityTargetType =  $("input:radio[name='activityTargetType']:checked").val();
                openDialog('customerVehicle/queryCustomerVehicleList?activityId='+ activityId + '&activityTargetType=' + activityTargetType + '&selectCustomers=' + $("#selectCustomers").val(),'选择用户',900,620);
            }

            function cancel(activityId){
                var index = parent.layer.getFrameIndex(window.name);
                if(index == undefined) {
                    window.location.href='/activity/editActivity?id='+ activityId;
                } else {
                    parent.layer.close(index);
                }
            }
    </script>


</body>

</html>